#!/usr/bin/python3
# -*- coding: utf-8 -*-
#======================================#
# @Author   : duanqizhong
# @time     : 2022-8-7 19:36
# @file     : conftest
# @Software : PyCharm
#======================================#

import pytest


@pytest.fixture(scope="module", autouse=True)
def mod_header(request):
    # print('\n<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
    # print(f'module        : {request.module.__name__}')
    # print('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<')
    pass


@pytest.fixture(scope="function", autouse=True)
def func_header(request):
    # print('\n<-------------------------------------->')
    # print(f'function      : {request.function.__name__}')
    # print(f'time          : {time.asctime()}')
    # print('<-------------------------------------->')
    pass


def pytest_configure(config):
    """marker:
    expect_ok: 与期望一致，正确传参
    expect_wrong: 与期望一致，错误传参
    expect_exception_ok: 可以预期的异常结果
    expect_exception_wrong: 不可预期的异常结果
    """
    marker_list = ["get", "post", "put", "delete", "expect_ok", "expect_wrong", "expect_exception_ok",
                   "expect_exception_wrong", "test_diff_tale"]
    for markers in marker_list:
        config.addinivalue_line("markers", markers)




def pytest_collection_modifyitems(items):
    """解决参数 汉字乱码"""
    for item in items:
        # item.name=item.name.encode("utf-8").decode("unicode_escape")
        item._nodeid = item.nodeid.encode("utf-8").decode("unicode_escape")
